import requests
import re
url = 'https://www.weather.com.cn/weather/101070102.shtml'
r = requests.get(url)
# 设置编码，不然会出现乱码≠≠≠=
r.encoding ='utf-8'
# print(r.text)
city = re.findall('<span class="name">([\u4e00-\u9fa5]*)</span>',r.text)
weather = re.findall('<span class="weather">([\u4e00-\u9fa5]*)</span>',r.text)
wd = re.findall('<span class="wd">(.*)</span>',r.text)
zs = re.findall('<span class="zs">([\u4e00-\u9fa5]*)</span>',r.text)

print(city)
# print(city,'\n', weather, '\n',wd,'\n', zs)
# 打包数据，转换成 字典
lst = []
# zip打包数据为 字典， 并循环填加到列表中
# for a,b,c,d in zip(city,weather,wd,zs):
#     lst.append([a,b,c,d])
#
# for item in lst:
#     for i in list(item):
#         print(i,'\t\t\t\t',end=' ')
#     print()


# 爬取图片保存在本地
# src = 'https://www.baidu.com/img/PCfb_5bf082d29588c07f842ccde3f97243ea.png'
# img = requests.get(src)
# with open('logo.png','wb') as f:
#     f.write(img.content)
